package com.aiti.lulian.controller;

import cn.hutool.core.util.IdUtil;
import com.aiti.base.core.base.controller.WebController;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.dto.*;
import com.aiti.lulian.entity.CardRecordSheet;
import com.aiti.lulian.service.ICardRecordSheetService;
import com.aiti.lulian.service.impl.CardRankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

@RestController
@RequestMapping("/card-rank")
public class CardRankController extends WebController {

    @Autowired
    private CardRankService cardRankService;

    /**
     * 名片人气榜页面列表
     * @param dto
     * @return
     */
    @GetMapping("/userCardRankList")
    public Message complete(CardBaseInfoRankDto dto) {
        return Message.success(cardRankService.userCardRankList(dto));
    }

    /**
     * 名片人气榜页面点击切换图标
     * @param userId
     * @return
     */
    @GetMapping("/changeUserCard")
    public Message changeUserCard(@RequestParam("userId") String userId) {
        return cardRankService.changeUserCard(userId);
    }

    /**
     * 当前用户排名情况
     * @param dto
     * @return
     */
    @GetMapping("/currentUserRank")
    public Message currentUserRank(CardBaseInfoRankDto dto) {
        return cardRankService.currentUserRank(dto);
    }

    /**
     * 发送短信验证码
     * @param mobile
     * @return
     */
    @GetMapping("/sendCode")
    public Message sendCode(@RequestParam("mobile") String mobile) {
        return cardRankService.sendCode(mobile);
    }

    /**
     * 提交认证信息
     * @param dto
     * @return
     */
    @PostMapping("/submitAuthentication")
    public Message submitAuthentication(@Validated @RequestBody  CardUserAuthenticationDto dto) {
        return cardRankService.submitAuthentication(dto);
    }

    /**
     * 是否已认证信息
     * @param dto
     * @return
     */
    @GetMapping("/isAuthenticated")
    public Message isAuthenticated(CardUserAuthenticationDto dto) {
        return cardRankService.isAuthenticated(dto);
    }

    /**
     * 提升排名页面-任务情况
     * @param dto
     * @return
     */
    @GetMapping("/userTaskInfo")
    public Message userTaskInfo(CardUserIncreaseRankDto dto) {
        return cardRankService.userTaskInfo(dto);
    }

    /**
     * 完成阅读手册
     * @param cardId
     * @return
     */
    @GetMapping("/finishRead")
    public Message finishRead(@RequestParam("cardId") String cardId) {
        return cardRankService.finishRead(cardId);
    }

    /**
     * 签到
     * @param cardId
     * @return
     */
    @GetMapping("/checkIn")
    public Message checkIn(@RequestParam("cardId") String cardId) {
        return cardRankService.checkIn(cardId);
    }

    /**
     * 名片人气榜记录点击浏览名片
     * @param dto
     * @return
     */
    @PostMapping("/recordBrowse")
    public Message recordBrowse(@RequestBody CardUserRankUserVisitHistoryDto dto) {
        return cardRankService.recordBrowse(dto);
    }


    @PostMapping("/task/complete")
    public Message complete(@RequestBody @Validated CardUserIncreaseRankDto dto) {
        return cardRankService.completeTask(dto);
    }
}
